﻿using System;
using System.Collections.Generic;
using System.Text;

using Weazel.Willows.Model;

namespace Weazel.Willows.RefinedModel
{
	public class QueueReaderTerminatorIpBlock 
		: Weazel.Gezel.Model.IPBlock
	{
		private Queue weazelQueue;

		public QueueReaderTerminatorIpBlock(Weazel.Gezel.Model.Model parent, string name, Queue weazelQueue)
			: base(parent, name)
		{
			this.weazelQueue = weazelQueue;
			
			// set the type of this ip block 
			this.ipType = "queue_reader_terminator";

			// get the type of the queue 
			Weazel.Willows.Model.Type type = weazelQueue.Type;

			// add ports
			OutPorts.Add("data_out", new Weazel.Gezel.Model.OutPort(this, "data_out", type.BitWidth, false, 0));
			OutPorts.Add("can_read", new Weazel.Gezel.Model.OutPort(this, "can_read", type.BitWidth, false, 1));
			InPorts.Add("do_read", new Weazel.Gezel.Model.InPort(this, "do_read", type.BitWidth, false, 2));

			// insert into model
			parent.IPBlocks.Add(name, this);
		}
	}
}
